package com.jichaoyun.dao.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.jichaoyun.model.entity.Realdata;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
* @author zhen
* @description 针对表【realData】的数据库操作Mapper
* @createDate 2023-11-16 19:42:41
* @Entity com.jichaoyun.model.entity.Realdata
*/
@Mapper
public interface RealdataMapper extends BaseMapper<Realdata> {

    Realdata getStationSingleInfoById(@Param("station_no") Integer station_no);

    @MapKey("record_time")
    List<Map<String,Object>> getRealDatabyId(@Param("station_no")  Integer station_no);


    List<Realdata> selectTop5Flow();

    List<Realdata> selectTop5Temp();

    List<Realdata> selectTop5Pres();

    List<Realdata> getMultiRealInfo();

    List<Realdata> getNearFlowBeforeTime(@Param("time") LocalDateTime time, @Param("stationList")List<Integer> stationList);

    List<Realdata> getNearFlowAfterTime(@Param("time") LocalDateTime time, @Param("stationList")List<Integer> stationList);

    Realdata selectRecentOneByStation(@Param("station_no")Integer station_no);

    List<Realdata> selectRecentTwoByStation(@Param("station_no")Integer station_no);

    @DS("sharding")
    Integer selectTotalBetweenTime(@Param("station")Integer station, @Param("start_time")LocalDateTime startTime, @Param("end_time")LocalDateTime endTime);

    @DS("sharding")
    int historyInsert(Realdata realdata);

    @DS("sharding")
    List<Realdata> historySelectPage(@Param("pageSize") Integer pageSize, @Param("offSize") Integer offSize, @Param("stationNo") Integer stationNo,
                                    @Param("start") LocalDateTime start, @Param("end") LocalDateTime end);

    @DS("sharding")
    Integer historySelectCount(@Param("stationNo")Integer stationNo,@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);

    @DS("sharding")
    List<Realdata> historySelect(@Param("stationNo")Integer stationNo,@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);

    @DS("sharding")
    Realdata historySelectOne(Integer stationNo, LocalDateTime start, LocalDateTime end);

    @DS("sharding")
    List<Float> getSubTotalFlowListByTimeRange(@Param("startTime") LocalDateTime start, @Param("endTime") LocalDateTime end, @Param("intervalTime") Integer interval, @Param("stationNo") Integer stationNo);

    @DS("sharding")
    List<Float> getFlowListByTimeRange(@Param("startTime") LocalDateTime start, @Param("endTime") LocalDateTime end, @Param("intervalTime") Integer interval, @Param("stationNo") Integer stationNo);

    @DS("sharding")
    Float getStationFlowSumByStationNoList(List<Integer> stationNoList, LocalDateTime start, LocalDateTime end);
    @DS("sharding")
    List<Realdata> historySelectAllBetweenTimeRange(List<Integer> stationNoList, LocalDateTime start, LocalDateTime end);

    @DS("sharding")
    Realdata historySelectOne1(Integer stationNo, LocalDateTime start, LocalDateTime end);

    @DS("sharding")
    List<Realdata> historySelectAll(List<Integer> stationNoList, LocalDateTime start, LocalDateTime end);

    @DS("sharding")
    Float getSubTotal(List<Integer> stationInfos, LocalDateTime start, LocalDateTime end);

    @DS("sharding")
    List<Realdata> selectListInSomeStation(List<Integer> threeStationNo, LocalDateTime start, LocalDateTime end);
}




